package com.nhjf.dao.total;

import org.apache.commons.lang.StringUtils;
import org.hibernate.Criteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.total.UserCount;
import com.nhjf.pojo.qo.total.UserCountQo;


@Repository
public class UserCountDao extends BaseDao<UserCount, UserCountQo>{

	@Override
	protected Criteria buildCriteria(Criteria criteria, UserCountQo qo) {
		// TODO Auto-generated method stub
        if(qo!=null){
            if(!StringUtils.isEmpty(qo.getUserName())) {
           	 criteria.add(Restrictions.like("userName", qo.getUserName(),MatchMode.ANYWHERE));
           }
           if(!StringUtils.isEmpty(qo.getUserPhone())) {
          	 criteria.add(Restrictions.eq("userPhone", qo.getUserPhone()));
          }

        }

        return criteria;
	}

	@Override
	protected Class<UserCount> getEntityClass() {
		// TODO Auto-generated method stub
		return UserCount.class;
	}

}
